#include <iostream>
using namespace std;

const int N = 110;

int n;
int a[N][N];
int f[N][N];

int main()
{
    freopen("cin.txt", "r", stdin);
    cin >> n;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= n; ++j)
            cin >> a[i][j];
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= n; ++j)             //[1][1]已经确定了，所以这里从[1][2]开始
            if (i == 1)                          //如果在上边界
                f[i][j] = f[i][j - 1] + a[i][j]; //那就没得选咯，只能从左边过来
            else if (j == 1)                     //如果在左边界
                f[i][j] = f[i - 1][j] + a[i][j]; //就只能从上面来
            else
                f[i][j] = min(f[i - 1][j] + a[i][j], f[i][j - 1] + a[i][j]); //那么就既可以从上面下来又可以从左边下来
    cout << f[n][n];
    return 0;
}